/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dca.sistemascontrole.sinais;

/**
 *
 * @author Rafael
 */
public class Aleatorio extends Sinal {

    private int cont = 0;
    private float value = 0;
    private float proxPeriodo;
    
    public Aleatorio(float periodo, float amplitude, float tempoAtuacao, float offset) {
        super(periodo, amplitude, tempoAtuacao, offset);
        proxPeriodo = periodo;
    }

    @Override
    protected float getValue(long t) {
        int x = (int) ((t - t0) / periodo);
        if (x >= cont ) {
            value = (float) (Math.random() * amplitude) - amplitude/2;
            proxPeriodo = (float) (Math.random() * periodo);
            System.out.println("Novo periodo = " + proxPeriodo);
            ++cont;
        }
        return value;
    }
}
